# -*- coding: utf-8 -*-

import datetime

from peewee import *
from base_model import BaseModel as CrudModel
from mocrud.admin import ModelAdmin
from mocrud.auth import BaseUser
from mocrud.auth import auth



class User(CrudModel,BaseUser):
    id = PrimaryKeyField()
    username = CharField(unique=True)
    password = CharField()
    email = CharField(unique=True)
    active = BooleanField()
    admin = BooleanField(default=False)

    def __unicode__(self):
        return self.username
    
class UserAdmin(ModelAdmin):
    verbose_name = u'用户'
    method_exclude = ['add', 'delete', 'export']
    columns = ('username', 'email', 'active', 'admin')

User.Admin = auth.get_model_admin(UserAdmin)
auth.User = User